package com.flyqiu.flow.api.service.base;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.flyqiu.common.tools.StringTools;
import com.flyqiu.flow.model.entity.Comment;

public interface FlowCommentService extends IService<Comment> {
    default void deleteComment(String procInstId) {
        deleteComment(procInstId, null);
    }

    default void deleteComment(String procInstId, String actId) {
        if (StringTools.isAllBlank(procInstId)) {
            throw new RuntimeException("procInstId cannot be null or empty");
        }
        LambdaQueryWrapper<Comment> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Comment::getProcInstId, procInstId);
        lambdaQueryWrapper.eq(StringTools.isNotBlank(actId), Comment::getActId, actId);
        remove(lambdaQueryWrapper);
    }

}
